<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script language="Javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/paging.js"></script>

<script language="JavaScript">
	$(document).ready(function() {
		$("#allsts").change(function() {
			var isChecked = $('.selsts').attr('checked') ? true : false;
			if (isChecked == false) {
				$(".selsts").attr('checked', true);
				$("input[name=book_id]").change();
			} else {
				$(".selsts").attr('checked', false);
				$("input[name=book_id]").change();
			}

		});

		$('#search').keyup(function() {
			searchTable($(this).val());
		});

		$("#example").tablesorter({
			// pass the headers argument and assing a object 
			headers : {
				// assign the secound column (we start counting zero) 
				0 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				// assign the third column (we start counting zero) 
				1 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				2 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				3 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				4 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				5 : {
					// disable it by setting the property sorter to false 
					sorter : false
				}
			}
		});
	});

	function searchTable(inputVal) {
		var table = $('#example');
		table.find('tr').each(function(index, row) {
			var allCells = $(row).find('td');
			if (allCells.length > 0) {
				var found = false;
				allCells.each(function(index, td) {
					var regExp = new RegExp(inputVal, 'i');
					if (regExp.test($(td).text())) {
						found = true;
						return false;
					}
				});
				if (found == true)
					$(row).show();
				else
					$(row).hide();
			}
		});
	}
</script>

<script type="text/javascript">
	function xyz(x) {

		if (x == "0") {
			for ( var i = 1; i <= 7; i++) {
				var j = (i * 2) - 1;
				var k = (i * 2);
				if (document.getElementById("c" + i).checked == false) {
					document.getElementById("t" + i).disabled = true;
					document.getElementById("d" + i).disabled = true;
					document.getElementById("a" + i).disabled = true;
					document.getElementById("n" + i).disabled = true;
					document.getElementById("p" + i).disabled = true;
					document.getElementById("pub" + i).disabled = true;
					document.getElementById("rb" + i).disabled = true;
					document.getElementById(j).disabled = true;
					document.getElementById(k).disabled = true;

					document.getElementById("t" + i).value = "";
					document.getElementById("d" + i).value = "";
					document.getElementById("a" + i).value = "";
					document.getElementById("n" + i).value = "";
					document.getElementById("p" + i).value = "";
					document.getElementById("pub" + i).value = "";
					document.getElementById("rb" + i).value = "";
					document.getElementById(j).value = "";
					document.getElementById(k).value = "";
				} else if (document.getElementById("c" + i).checked == true) {
					document.getElementById("t" + i).disabled = false;
					document.getElementById("d" + i).disabled = false;
					document.getElementById("a" + i).disabled = false;
					document.getElementById("n" + i).disabled = false;
					document.getElementById("p" + i).disabled = false;
					document.getElementById("pub" + i).disabled = false;
					document.getElementById("rb" + i).disabled = false;
					if (document.getElementById(j).disabled == true
							&& document.getElementById(k).disabled == true
							&& document.getElementById("categoryRadioId1" + j).checked == true) {
						document.getElementById(j).disabled = false;
					} else if (document.getElementById(j).disabled == true
							&& document.getElementById(k).disabled == true
							&& document.getElementById("categoryRadioId2" + k).checked == true) {
						document.getElementById(k).disabled = false;
					}
				}
			}
		}
		if (x != "0") {

			var y, z, ybytwo;
			if (x % 2 == 0) {
				y = x;
			} else {
				y = x + 1;
			}
			ybytwo = (y / 2);
			if (document.getElementById("c" + ybytwo).checked == true) {
				//	if(document.getElementById("categoryRadioId1").checked==true){alert("1 is checked");}
				if (x == "1") {
					document.getElementById("2").disabled = true;
					document.getElementById("2").value = "";
					document.getElementById("1").disabled = false;
				} else if (x == "2") {
					document.getElementById("1").disabled = true;
					document.getElementById("1").value = "";
					document.getElementById("2").disabled = false;
				}

				if (x == "3") {
					document.getElementById("4").disabled = true;
					document.getElementById("4").value = "";
					document.getElementById("3").disabled = false;
				} else if (x == "4") {
					document.getElementById("3").disabled = true;
					document.getElementById("3").value = "";
					document.getElementById("4").disabled = false;
				}
				if (x == "5") {
					document.getElementById("6").disabled = true;
					document.getElementById("6").value = "";
					document.getElementById("5").disabled = false;
				} else if (x == "6") {
					document.getElementById("5").disabled = true;
					document.getElementById("5").value = "";
					document.getElementById("6").disabled = false;
				}
				if (x == "7") {
					document.getElementById("8").disabled = true;
					document.getElementById("8").value = "";
					document.getElementById("7").disabled = false;
				} else if (x == "8") {
					document.getElementById("7").disabled = true;
					document.getElementById("7").value = "";
					document.getElementById("8").disabled = false;
				}
				if (x == "9") {
					document.getElementById("10").disabled = true;
					document.getElementById("10").value = "";
					document.getElementById("9").disabled = false;
				} else if (x == "10") {
					document.getElementById("9").disabled = true;
					document.getElementById("9").value = "";
					document.getElementById("10").disabled = false;
				}
				if (x == "11") {
					document.getElementById("12").disabled = true;
					document.getElementById("12").value = "";
					document.getElementById("11").disabled = false;
				} else if (x == "12") {
					document.getElementById("11").disabled = true;
					document.getElementById("11").value = "";
					document.getElementById("12").disabled = false;
				}
				if (x == "13") {
					document.getElementById("14").disabled = true;
					document.getElementById("14").value = "";
					document.getElementById("13").disabled = false;
				} else if (x == "14") {
					document.getElementById("13").disabled = true;
					document.getElementById("13").value = "";
					document.getElementById("14").disabled = false;
				}
			}
		}
	}
</script>

<link rel="stylesheet" type="text/css" href="css/style.css">
<script>
	function PopupCenter(pageURL, title, w, h) {
		var left = (screen.width / 2) - (w / 2);
		var top = (screen.height / 2) - (h / 2);
		var targetWin = window
				.open(
						pageURL,
						title,
						'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='
								+ w
								+ ', height='
								+ h
								+ ', top='
								+ top
								+ ', left=' + left);
	}
	function reload() {
		window.location.href = window.location.href;
	}
</script>

</head>
<body onload="xyz(0)">
	<div align="right">
		<a href="javascript:void(0);"
			onclick="PopupCenter('admin/UploadBookExcel.jsp','batch',300,300);">Upload
			an Excel Sheet</a>Search Entries:<input type="text" id="search" />
	</div>
	<form action="submitStudent.action?submit=submit" method="post">
		<table id="example" class="tablesorter">
			<thead>
				<tr>
					<th><input type="checkbox" id="allsts" />
					</th>
					<th>Name</th>
					<th>Roll No</th>
					<th>Mobile Number</th>
					<th>Phone Number</th>
					<th>Address Line 1</th>
					<th>Address Line 2</th>
					<th>City</th>
					<th>State</th>
					<th>email_id</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><input type="checkbox" class="selsts" onchange="xyz(0)"
						name="student_name" />
					</td>
					<td><input type="text" name="roll_number" />
					</td>
					<td><input type="text" name="mobile_number" />
					</td>
					<td><input type="text" name="phone_number" />
					</td>
					<td><input type="text" name="address_line_1" />
					</td>
					<td><input type="text" name="address_line_2" />
					</td>
					<td><input type="text" name="city" />
					</td>
					<td><input type="text" name="state" />
					</td>
					<td><input type="text" name="email_id" />
					</td>
					<td><input type="Submit" value="Submit" />
					</td>
				</tr>
			</tbody>

		</table>
	</form>
</body>
</html>